package com.hao.netty.handler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;

/**
 * TODO
 *
 * @author 97472
 * @version 1.0
 * @date 2021/11/30 12:38
 */
public class ChatServerInitializer extends ChannelInitializer<SocketChannel> {

    // 对管道进行初始化
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();
        pipeline.addLast(new StringDecoder());
        pipeline.addLast(new StringEncoder());
        pipeline.addLast(new ChatServerChannelInHandler());
    }

}
